public class Test {
    public boolean isLegal(char ch){
        if(ch>='a' && ch<='z'
                || ch>='0' && ch<='9'){
            return true;
        }
        else{
            return false;
        }
    }
    public boolean isPalindrome(String s) {
        s=s.toLowerCase();
        int left=0;
        int right=s.length()-1;
        while(left < right){
            while(left < right&&!isLegal(s.charAt(left))){
                left++;
            }
            while(left < right&&!isLegal(s.charAt(right))){
                right--;
            }
            if(s.charAt(left)!=s.charAt(right)){
                return false;
            }else{
                left++;
                right--;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        String s1="0P";
        Test test=new Test();
        System.out.println(test.isPalindrome(s1));
    }
}
